package com.aier.common.common;

import java.util.List;
import java.util.TimerTask;

import javax.annotation.Resource;

import com.aier.admin.entity.SysEmail;
import com.aier.common.service.ISysEmailService;
import com.aier.common.service.IUserSendEmailService;



public class SysTimeSendEmail extends TimerTask {
    private Integer error_max_size;
    
    @Resource(name = "userSendEmailService")
    private IUserSendEmailService userSendEmailService;
    
    @Resource(name = "sysEmailService")
    private ISysEmailService sysEmailService;

    /**
     * 定时指定发送 邮件发送器中等待发送的邮件
     */

    @Override
    public void run() {
        List<SysEmail> ls = null;
        ls = sysEmailService.showAllEmail();
        for(SysEmail se:ls){
            if(se.getSize()>=error_max_size){
                sysEmailService.updateForErrorEmail(se);
            }
            switch(se.getType()){
                case IUserSendEmailService.TYPE_USER:
                    userSendEmailService.updateSendHtmlMail(se);
                    break;
            }
        }
    }

    
    public Integer getError_max_size() {
        return error_max_size;
    }

    public void setError_max_size(Integer error_max_size) {
        this.error_max_size = error_max_size;
    }


    public IUserSendEmailService getUserSendEmailService() {
        return userSendEmailService;
    }


    public void setUserSendEmailService(IUserSendEmailService userSendEmailService) {
        this.userSendEmailService = userSendEmailService;
    }


    public ISysEmailService getSysEmailService() {
        return sysEmailService;
    }


    public void setSysEmailService(ISysEmailService sysEmailService) {
        this.sysEmailService = sysEmailService;
    }

    
}
